﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RoutingTable
{
    public partial class F_BS : Form
    {
		// Define Clase    ************************************************************************
		NODE ND         = new NODE();

        // 전역 변수 선언  *************************************************************************
        public  int[]       nodeID      = new int[NODE.TNODE];
		public  float[]     energy      = new float[NODE.TNODE];
		public  int[]       parentID    = new int[NODE.TNODE];
		public  int[]       hc          = new int[NODE.TNODE];
		public	int[]		vc			= new int[NODE.TNODE];
		public	int[]		partID		= new int[NODE.TNODE];
		public	string[]	keys		= new string[NODE.TNODE];
        public  float[]     nodeX       = new float[NODE.TNODE];
        public  float[]     nodeY       = new float[NODE.TNODE];		
        public  float[]     distance    = new float[NODE.TNODE];
		public	float[]		psm			= new float[NODE.TNODE];
		public	float[]		pdm			= new float[NODE.TNODE];
		

        // DEFINE const ***************************************************************************
        public  const   int BS_ID   = 0;
        public  const   int BS_X    = 433;
        public  const   int BS_Y    = 357;
        public  const   int PRNT_ID = -1;
        public  const   int LMT_HC  = 50;
        public  const   int ENG     = 0;

        public F_BS()
        {
            InitializeComponent();
        }

        public F_BS( int[]      id
					 , float[] energy
					 , int[] prnt
					 , int[] hc
					 , int[] vc
					 , int[] partID
					 , string[] keys
                     , float[]  x
                     , float[]  y                     
                     , float[]  dst
					 , float[] psm
					 , float[] pdm
					 , int rrc
					 , float EVLT
				   )
        {
            InitializeComponent();

			//float	sumE	= -1.0f;
			int		sumHC	= -1;
			int		sumVC	= -1;


            GRID.Rows.Add( NODE.TNODE - 1);

            for (int i = 0; i < NODE.TNODE; i++)
            {
                GRID[0, i].Value = id[i];
				GRID[1, i].Value = energy[i];
				GRID[2, i].Value = prnt[i];
				GRID[3, i].Value = hc[i];
				GRID[4, i].Value = vc[i];
				GRID[5, i].Value = partID[i];
				GRID[6, i].Value = keys[i];
                GRID[7, i].Value = x[i];
                GRID[8, i].Value = y[i];
				GRID[9, i].Value = dst[i];
				GRID[10,i].Value = dst[i];
				GRID[11,i].Value = dst[i];
				
				if ( i != 0 )
				{
					//sumE	= sumE  + energy[i];
					sumHC	= sumHC + hc[i];
					sumVC	= sumVC + vc[i];
				}
            }

			PrintOnForm( rrc, sumHC, sumVC, EVLT );
		}

        // 베이스 스테이션 만들기 ******************************************************************
        public void MakeBS( NODE nd )
        {
            nd.nodeID   = BS_ID;
            nd.nodeX    = BS_X;
            nd.nodeY    = BS_Y;
            nd.parentID = PRNT_ID;
            nd.energy   = ENG;
        } // public void MakeBS( NODE nd )


		//  Initial BS Information	***************************************************************
        public void InitBSEnergy( NODE nd )
        {
            nd.energy	= ENG;
		} // public void InitBSEnergy( NODE nd )

		public void PrintOnForm( int rrc, int HC, int VC, float EVLT )
		{
			//double	result = 0.0;

			TB_RR.Text = string.Format( "{0}", rrc );
			TB_SH.Text = string.Format( "{0}", HC );
			TB_SV.Text = string.Format( "{0}", VC );

			//result = ND.EvaluateResult( VC, rrc, HC );
			TB_RS.Text = string.Format( "{0}", EVLT );
		}
    }
}
